home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16274 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: kbad.eglin.af.mil!rpi!not-for-mail
  2. From: Kyle.F.Downey@williams.edu (Kyle F. Downey)
  3. Newsgroups: comp.lang.c++.moderated,comp.lang.c++
  4. Subject: redefining stdout for all C/C++ output calls
  5. Date: 8 Apr 1996 21:40:44 -0000
  6. Organization: Williams College, Williamstown MA
  7. Sender: cppmods@netlab.cs.rpi.edu
  8. Approved: vandevod@cs.rpi.edu
  9. Message-ID: <4kc14s$iai@netlab.cs.rpi.edu>
  10. NNTP-Posting-Host: netlab.cs.rpi.edu
  11. X-Original-Date: 8 Apr 1996 13:55:41 -0400
  12.  
  13. Is there any way to redefine stdout that will work for both C-style
  14. (printf, etc.) and C++-style (streams) output? I would want a C++
  15. method that does this
  16.  
  17. void f() {
  18.     printf("Here's a C-style output line.\n");
  19.     cout << "Here's another using streams..." << endl;
  20. }
  21.  
  22. to send the output to a different stream. I know there's tie() for
  23. streams, but what about printf()? The idea here is to take a
  24. text-based C++ program and "capture" all screen writes to send them to
  25. an GUI window "stream." I want to do it so the text program need not be
  26. rewritten. So you would take the main() function of the program and
  27. call it, say, tmain() and pass it as a function pointer to a program
  28. that would run it after redefining stdout.
  29.  
  30. Any ideas?
  31.  
  32. (If you've seen the SIOUX library under the Metrowerks C/C++ compiler,
  33. you'll know what I am thinking about.)
  34.  
  35. --kd
  36.  
  37.       [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
  38.       [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
  39.       [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
  40.       [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
  41.